<!DOCTYPE html>
<html>
<head>
	<title>添加界面</title>
</head>
<body>
<center>
	用户名:<input type="text" name="name" id="name"><br>
	密码:<input type="password" name="pwd" id="pwd"><br>
	手机号:<input type="text" name="tel" id="tel"><input type="button" name="" value="发送验证码" id="send"><br>
	验证码:<input type="text" name="code" id="code"><br>
	<input type="button" id="sub" name="" value="注册">
</center>
</body>
</html>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript">
	$("#send").click(function(){
		var tel = $("#tel").val();
		if (tel=="") {
			alert("请输入手机号");
			return false;
		}
		$.ajax({
			url:"SendTemplateSMS.php",
			data:{tel,tel},
			dataType:"json",
			type:"post",
			success:function(res){
				console.log(res);
			}
		});
	})
	$("#sub").click(function(){
		var tel = $("#tel").val();
		var code = $("#code").val();
		var name = $("#name").val();
		if (name=='') {
			alert("请输入用户名");
			return false;
		}
		var pwd = $("#pwd").val();
		if (pwd.length<8||pwd.length>16) {
			alert("密码为8-16位");
			return false;
		}
		$.ajax({
			url:"regis.php",
			data:{tel:tel,code:code,name:name,pwd:pwd},
			dataType:"json",
			type:"post",
			success:function(res){
				alert(res.msg);
			}
		});
	})
</script>
